#!/usr/bin/perl
#domain_setting.cgi

require './mdmjobs-lib.pl';
&ReadParse();

&header($text{'domain_detail'}, "", "index", 0, 1,undef,undef);
print "<form action=mdm_domain.cgi method=post onsubmit='return checkselect(\"$text{'err_nomember'}\",\"$text{'err_noname'}\");'>\n";
print "<table class=mode1 border=0 cellspacing=0 cellpadding=0>\n";
print "<tr><td>\n";
local $grpinfo=&foreign_call("mdmgroups","get_groupinfo");
local %grpinfo=%$grpinfo;
local @group = split (/,/,$grpinfo{'[group]'});
&select_members(\@group);	
print "</td></tr>\n";

print "<tr><td><table class=mode1 border=0 cellspacing=0 cellpadding=2>\n";
print "<hr align=left width=550>\n";
print "<tr><td><table class=mode1 border=0 cellspacing=0 cellpadding=2>\n";
print "<h4>$text{'index_setdomain'}</h4>\n";
print "$text{'index_setdomainmsg'}<p>\n";
print "</table></td></tr>\n";
print "<tr><td><table class=mode1 border=0 cellspacing=0 cellpadding=4>\n";
print "<tr><td><input type=radio name=select checked value='workgroup'>&nbsp;<b>$text{'workgroup'}</b>&nbsp;&nbsp;<input value='' name=workgroup></td>\n";
print "<tr><td><input type=radio name=select value='domain'>&nbsp;<b>$text{'domain'}</b>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input value='' name=domain></td>\n";
print "<tr><td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type=checkbox name=chkaddr value='check' onclick=\"checkaddr();\">&nbsp;$text{'pdcaddress'}</td><td><input disabled value='' name=pdcaddress></td>\n";
print "<tr><td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$text{'pdcuser'}</td><td><input value='' name=pdcuser></td>\n";
print "<tr><td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$text{'pdcpass'}</td><td><input type=password value='' name=pdcpass></td>\n";
print "</table></td></tr><tr><td><table class=mode1 border=0 cellspacing=0 cellpadding=2>\n";
print "<tr><td align=left><input type=submit class=button value=\"$text{'index_submit'}\"></td></tr>\n";
print "</table></td></tr></table></td></tr>\n";

print "</table></form>\n";
print <<EOF;
<script>
function checkaddr()
{
	if (document.forms[0].chkaddr.checked){
		document.forms[0].pdcaddress.disabled = false;
	}else{
		document.forms[0].pdcaddress.disabled = true;
	}
}
function checkselect(alertmessg1,alertmessg2)
{
	if(document.forms[0].memberlist.options.length == 0){
		alert(alertmessg1);
		return false;
	}
	
	if(!confirm("$text{'msg_confirm'}")){
                return false;
        }
	
	if(document.forms[0].listinput.value == ""){
		if(document.forms[0].memberlist.options.length > 0){
			document.forms[0].listinput.value = document.forms[0].memberlist.options[0].text;
		}else{
			document.forms[0].listinput.value = "";
		}	

		for(i = 1; i < document.forms[0].memberlist.options.length; i++){
			document.forms[0].listinput.value += "," + document.forms[0].memberlist.options[i].text;
		}
	}
}
</script>
EOF

&footer("index.cgi", $text{'index_title'});
1;
